package com.zq.it.dao.impl.admin;

import java.util.Collection;
import java.util.List;

import org.springframework.orm.hibernate3.HibernateTemplate;

import com.zq.it.dao.admin.TAddressDao;
import com.zq.it.dao.impl.BaseDao;
import com.zq.it.pojo.Address;

public class TAddressDaoImpl extends BaseDao<Address> implements TAddressDao {
  /*public static final Logger logger=t(AddressDaoImpl.class);*/
	@Override
	public void saveAddressEty(Address addr){
    	getHibernateTemplate().save(addr);
	}
	@Override
	public void deleteAddressEtyByID(Integer id){	
		deleteEntity("delete Address as addr where addr="+id);
	}

	@Override
	public List<Address> findAddressEtyList() {
		return getHibernateTemplate().find("from Address");
		// TODO Auto-generated method stub	
	}

	@Override
	public List findAddressEtyById(Integer id) {
		return getHibernateTemplate().find("from Address where addressId=?",id);
		// TODO Auto-generated method stub	
	}

	@Override
	public List findAddressEtyByName(String name) {
		
		return getHibernateTemplate().find("from Address as adr where adr.addressName like '%"+name+"%'");
		// TODO Auto-generated method stub
	
	}
@Override
public List findAdrByHQL(String hql){
	//"select new com.zq.it.pojo.Address(addressId,addressName) from Address"
	return findEtyByHql(hql);
}

	@Override
	public void updateAddressEty(Address address) {
		getHibernateTemplate().update(address);
		// TODO Auto-generated method stub
		
	}

	@Override
	public List findAddressEtyByExmp(Address address) {
		// TODO Auto-generated method stub
		return getHibernateTemplate().findByExample(address);
	}
	@Override
	public void deleteAllEty(Integer[] ids){		
		HibernateTemplate ht=getHibernateTemplate();
		for(Integer i:ids)
		  ht.delete(ht.load(Address.class,i));
	}
	@Override
	public void deleteAddressEtyByObj(Address address){
		getHibernateTemplate().delete(address);
	}
	@Override
	public void saveAddressEtyList(Collection<Address> collection){
		getHibernateTemplate().saveOrUpdateAll(collection);
	}
	
	@Override
	public List findAdrBySQL(String sql){
		return findEtyBySQL(sql);
	}
}
